<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Setting_pages extends Admin_Controller{

	function Setting_pages(){
        parent::Admin_Controller();
        $CI = & get_instance();    
	}
	
	function index(){
		//$this->change_label();
	}
    
	function lists()
	{
		$CI = & get_instance();

		$CI->load->module_library('users.auth');
        $auth_data = $CI->auth->get_auth_data();
		$CI->load->library('fckeditor');
        $CI->fckeditor->SetPathOfFranchise();
        
		$page_id = $CI->input->post('page_id')?$CI->input->post('page_id'):2;
		
		$select = 'SELECT p.'.PAGE_VISIBLE.', p.'.PAGE_ACTIVE.', p.'.PAGE_CONTENT_MIDDLE.', p.'.PAGE_META_TITLE.', p.'.PAGE_META_DESCRIPTION.', p.'.PAGE_META_KEYWORD.', p.'.PAGE_CONTENT_LEFT.', p.'.PAGE_CONTENT_RIGHT.','.NAVIGATION_ITEM_VISIBLE;
		$from = ' FROM '.PAGE.' p, '.NAVIGATION.' n ';
		$cond = ' WHERE p.'.PAGE_FRANCHISE_ID.' = '.$auth_data['admin_id'];
		$cond .= ' AND p.'.PAGE_PAGE_ID.'='.$page_id;
	
        $sql = $select.$from.$cond;
        $results = $CI->db->query($sql)->row();
		$this->add('results', $results); 
		$CI->fckeditor->Value = $results->{PAGE_CONTENT_MIDDLE};
		$CI->fckeditor->Height = 400;
        $CI->fckeditor->InstanceName = 'middle_content';
        $fck_middle_content = $CI->fckeditor->CreateHtml();
        $this->add('fck_middle_content', $fck_middle_content); 
		
		$this->module_toolbar();
		$this->module_navigation('Trang Giới Thiệu');
		
		
		$this->add('page_id', $page_id); 
        $this->view('content');
	}
	
	
}